import { createApp } from "vue";
import router from "./router";
import App from "./App.vue";
import { createPinia } from "pinia";
import "vant/lib/index.css";
import "@/assets/styles/global.less";
import VueLazyload from "vue-lazyload";
import defaultImg from "@/assets/images/default.png";
const pinia = createPinia();

createApp(App)
  .use(pinia)
  .use(router)
  .use(VueLazyload, {
    preLoad: 1.3,
    error: defaultImg,
    // loading: defaultImg,
    attempt: 1,
  })
  .mount("#app");

// add eruda to test env
if (!import.meta.env.PROD) {
  const script = window.document.createElement("script");
  script.src = "//cdn.jsdelivr.net/npm/eruda";
  window.document.body.append(script);
  const timer = window.setInterval(() => {
    if (window.eruda) {
      window.eruda.init();
      window.clearInterval(timer);
    }
  }, 50);
}
